﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace ScoreMS.Views
{
    /// <summary>
    /// Examination_paperAdd.xaml 的交互逻辑
    /// </summary>
    public partial class Examination_paperAdd : Page
    {
        public Examination_paperAdd()
        {
            InitializeComponent();

            this.Loaded += new RoutedEventHandler(Examination_paperAdd_Loaded);
        }

        void Examination_paperAdd_Loaded(object sender, RoutedEventArgs e)
        {
            this.cbxCourse.ItemsSource = BLL.CourseBS.GetCourseList(App.teacher_id);
        }

        /// <summary>
        /// 提交
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            if (cbxCourse.SelectedIndex == -1
                || txtbig.Text.Trim() == ""
                || txtsmall.Text.Trim() == "")
            {
                MessageBox.Show("请填写完整！", "提示");
                return;
            }
            if (BLL.Examination_paparBS.AddExamination_papar(new Model.Examination_papar()
            {
                course_id = (cbxCourse.SelectedItem as Model.Course).course_id,
                bigquestion_count = int.Parse(txtbig.Text.Trim()),
                smallquestion_count = int.Parse(txtsmall.Text.Trim())
            }))
            {
                MessageBox.Show("恭喜！添加成功！", "提示");
            }
            else
            {
                MessageBox.Show("添加失败！请确保输入数据正确！", "警告");
            }
        }
    }
}
